package com.example.demo.service.impl;

import com.example.demo.mapper.yinsidao;
import com.example.demo.pojo.yinsii;
import com.example.demo.service.sv.yinsi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class yinsiimpl implements yinsi {

    @Autowired
   yinsidao yinsidao;
    @Override
    public String chazhanji(String zhang) {
        return yinsidao.cha(zhang).getZhanji();
    }

    @Override
    public void updatedengji(String zhang,int jingyan){
        yinsii yinsii=yinsidao.cha(zhang);
        if((yinsii.getJingyan()+jingyan)>10)
             yinsidao.updatedengji(zhang,yinsii.getDengji()+1,yinsii.getJingyan()+jingyan-10);
    }

    @Override
    public void updatejifen(String zhang,int jifen){
        yinsii yinsii=yinsidao.cha(zhang);
         if(yinsii.getJifen()>jifen)
        yinsidao.updatejifen(zhang, yinsii.getJifen()-jifen);
    }

}
